// api管理
import request from '../utils/request';

export default {
  // ------------   用户 有关的接口   ------------
  // 登录API
  login(form = {}) {
    return request({ method: 'post', url: '/user/login', data: form, mock: false });
  },
  // 获取用户列表
  getUserList(params = {}) {
    return request({ method: 'get', url: '/user/list', data: params, mock: false });
  },
  // 获取用户能访问的菜单
  getUserMenu(params = {}) {
    return request({ method: 'get', url: '/user/userMenu', data: params, mock: false });
  },
  // 获取用户列表  只有名称和id
  getAllUserList(params = {}) {
    return request({ method: 'get', url: '/user/allList', data: params, mock: false });
  },
  // 新增/编辑 用户
  userSubmit(params = {}) {
    return request({ method: 'post', url: '/user/operate', data: params, mock: false });
  },
  // 删除用户
  delUser(params = {}) {
    return request({ method: 'post', url: '/user/delete', data: params, mock: false });
  },

  // ------------   菜单 有关的接口   ------------
  // 菜单列表
  getMenuList(params = {}) {
    return request({ method: 'get', url: '/menu/list', data: params, mock: false });
  },
  // 新增/编辑/删除 菜单
  menuSubmit(params = {}) {
    return request({ method: 'post', url: '/menu/operate', data: params, mock: false });
  },

  // ------------   角色 有关的接口   ------------
  // 获取角色列表  只有名称和id
  getRoleAllList() {
    return request({ method: 'get', url: '/role/allList', data: {}, mock: false });
  },
  getRoleList(params = {}) {
    return request({ method: 'get', url: '/role/list', data: params, mock: false });
  },
  // 新增/编辑/删除 菜单
  roleSubmit(params = {}) {
    return request({ method: 'post', url: '/role/operate', data: params, mock: false });
  },
  // 新增/编辑/删除 菜单
  roleUpdatePermission(params = {}) {
    return request({ method: 'post', url: '/role/permission', data: params, mock: false });
  },

  // ------------   部门 有关的接口   ------------
  // 获取部门列表
  getDeptList(params = {}) {
    return request({ method: 'get', url: '/dept/list', data: params, mock: false });
  },
  // 编辑部门列表
  deptOperate(params = {}) {
    let { action } = params;
    delete params.action;
    return request({ method: 'post', url: `/dept/${action}`, data: params, mock: false });
  },

  // ------------   休假审批 有关的接口   ------------
  getLeaveList(params = {}) {
    return request({ method: 'get', url: '/leave/list', data: params, mock: false });
  },
  // 休假操作
  leaveOperate(params = {}) {
    let { action } = params;
    delete params.action;
    return request({ method: 'post', url: `/leave/${action}`, data: params, mock: false });
  },
  // 审核操作
  leaveApprove(params = {}) {
    let { action } = params;
    delete params.action;
    return request({ method: 'post', url: `/leave/${action}`, data: params, mock: false });
  },
  // 审批数量
  getNoticeCount() {
    return request({ method: 'get', url: '/leave/count', data: {}, mock: false });
  },
};
